package com.clip.action;

import com.opensymphony.xwork2.ActionSupport;
@Deprecated
public class MonthViewAction extends ActionSupport{
//
//	private static final long serialVersionUID = -2171242865160360746L;
//	
//	@Autowired
//	private EventService eventService;
////	@Autowired
////	private MemoEventService memoEventService;
////	@Autowired
////	private ClockEventService clockEventService;
////	@Autowired
////	private DateEventService dateEventService;
//	@Autowired
//	private ForbiddenEventService forbiddenEventService;
//	@Autowired
//	private UserDateService userDateService;
//	@Autowired
//	private SystemDateService systemDateService;
//	
//	
//	private SimpleDateFormat dateFormat=new SimpleDateFormat("MMdd");
//	
//	public void getPrevYear(){
//		Map<String,Object> jsonMap = new HashMap<String, Object>();
//		Calendar calendar=Calendar.getInstance();
//		Calendar now=(Calendar) calendar.clone();
//		calendar.clear(Calendar.MILLISECOND);
//		calendar.clear(Calendar.SECOND);
//		calendar.clear(Calendar.MINUTE);
//		calendar.set(Calendar.HOUR_OF_DAY, 0);
//		calendar.set(Calendar.YEAR, year);
//		calendar.set(Calendar.MONTH, month);
//		calendar.set(Calendar.DAY_OF_MONTH, 1);
//		calendar.add(Calendar.YEAR, -1);
//		int year = calendar.get(Calendar.YEAR);
//		int month = calendar.get(Calendar.MONTH);
//		int maxday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
//		int dayofmonth =0;
//		if(now.get(Calendar.YEAR)==calendar.get(Calendar.YEAR)&&now.get(Calendar.MONTH)==calendar.get(Calendar.MONTH)){
//			dayofmonth = now.get(Calendar.DAY_OF_MONTH);
//		}else{
//			dayofmonth =0;
//		}
//		jsonMap.put("year", year);
//		jsonMap.put("month", month);
//		jsonMap.put("maxday", maxday);
//		jsonMap.put("dayofmonth", dayofmonth);
//		
//		String jsonStr = com.clip.util.json.JSONObject.toJSONString(jsonMap);
//		Struts2Utils.renderText(jsonStr);
//	}
//	public void getNextYear(){
//		Map<String,Object> jsonMap = new HashMap<String, Object>();
//		Calendar calendar=Calendar.getInstance();
//		Calendar now=(Calendar) calendar.clone();
//		calendar.clear(Calendar.MILLISECOND);
//		calendar.clear(Calendar.SECOND);
//		calendar.clear(Calendar.MINUTE);
//		calendar.set(Calendar.HOUR_OF_DAY, 0);
//		calendar.set(Calendar.YEAR, year);
//		calendar.set(Calendar.MONTH, month);
//		calendar.set(Calendar.DAY_OF_MONTH, 1);
//		calendar.add(Calendar.YEAR, +1);
//		int year = calendar.get(Calendar.YEAR);
//		int month = calendar.get(Calendar.MONTH);
//		int maxday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
//		int dayofmonth =0;
//		if(now.get(Calendar.YEAR)==calendar.get(Calendar.YEAR)&&now.get(Calendar.MONTH)==calendar.get(Calendar.MONTH)){
//			dayofmonth = now.get(Calendar.DAY_OF_MONTH);
//		}else{
//			dayofmonth =0;
//		}
//		jsonMap.put("year", year);
//		jsonMap.put("month", month);
//		jsonMap.put("maxday", maxday);
//		jsonMap.put("dayofmonth", dayofmonth);
//		
//		String jsonStr = com.clip.util.json.JSONObject.toJSONString(jsonMap);
//		Struts2Utils.renderText(jsonStr);
//	}
//	public void getPrevMonth(){
//		Map<String,Object> jsonMap = new HashMap<String, Object>();
//		Calendar calendar=Calendar.getInstance();
//		Calendar now=(Calendar) calendar.clone();
//		calendar.clear(Calendar.MILLISECOND);
//		calendar.clear(Calendar.SECOND);
//		calendar.clear(Calendar.MINUTE);
//		calendar.set(Calendar.HOUR_OF_DAY, 0);
//		calendar.set(Calendar.YEAR, year);
//		calendar.set(Calendar.MONTH, month);
//		calendar.set(Calendar.DAY_OF_MONTH, 1);
//		calendar.add(Calendar.MONTH, -1);
//		int year = calendar.get(Calendar.YEAR);
//		int month = calendar.get(Calendar.MONTH);
//		int maxday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
//		int dayofmonth =0;
//		if(now.get(Calendar.YEAR)==calendar.get(Calendar.YEAR)&&now.get(Calendar.MONTH)==calendar.get(Calendar.MONTH)){
//			dayofmonth = now.get(Calendar.DAY_OF_MONTH);
//		}else{
//			dayofmonth =0;
//		}
//		jsonMap.put("year", year);
//		jsonMap.put("month", month);
//		jsonMap.put("maxday", maxday);
//		jsonMap.put("dayofmonth", dayofmonth);
//		
//		String jsonStr = com.clip.util.json.JSONObject.toJSONString(jsonMap);
//		Struts2Utils.renderText(jsonStr);
//	}
//	public void getNextMonth(){
//		Map<String,Object> jsonMap = new HashMap<String, Object>();
//		Calendar calendar=Calendar.getInstance();
//		Calendar now=(Calendar) calendar.clone();
//		calendar.clear(Calendar.MILLISECOND);
//		calendar.clear(Calendar.SECOND);
//		calendar.clear(Calendar.MINUTE);
//		calendar.set(Calendar.HOUR_OF_DAY, 0);
//		calendar.set(Calendar.YEAR, year);
//		calendar.set(Calendar.MONTH, month);
//		calendar.set(Calendar.DAY_OF_MONTH, 1);
//		calendar.add(Calendar.MONTH, +1);
//		int year = calendar.get(Calendar.YEAR);
//		int month = calendar.get(Calendar.MONTH);
//		int maxday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
//		int dayofmonth =0;
//		if(now.get(Calendar.YEAR)==calendar.get(Calendar.YEAR)&&now.get(Calendar.MONTH)==calendar.get(Calendar.MONTH)){
//			dayofmonth = now.get(Calendar.DAY_OF_MONTH);
//		}else{
//			dayofmonth =0;
//		}
//		jsonMap.put("year", year);
//		jsonMap.put("month", month);
//		jsonMap.put("maxday", maxday);
//		jsonMap.put("dayofmonth", dayofmonth);
//		
//		String jsonStr = com.clip.util.json.JSONObject.toJSONString(jsonMap);
//		Struts2Utils.renderText(jsonStr);
//	}
//	public void getUserDefinedMonth(){
//		Map<String,Object> jsonMap = new HashMap<String, Object>();
//		Calendar calendar=Calendar.getInstance();
//		Calendar now=(Calendar) calendar.clone();
//		calendar.clear(Calendar.MILLISECOND);
//		calendar.clear(Calendar.SECOND);
//		calendar.clear(Calendar.MINUTE);
//		calendar.set(Calendar.HOUR_OF_DAY, 0);
//		calendar.set(Calendar.YEAR, year);
//		calendar.set(Calendar.MONTH, month);
//		calendar.set(Calendar.DAY_OF_MONTH, 1);
//		int year = calendar.get(Calendar.YEAR);
//		int month = calendar.get(Calendar.MONTH);
//		int maxday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
//		int dayofmonth =0;
//		if(now.get(Calendar.YEAR)==calendar.get(Calendar.YEAR)&&now.get(Calendar.MONTH)==calendar.get(Calendar.MONTH)){
//			dayofmonth = now.get(Calendar.DAY_OF_MONTH);
//		}else{
//			dayofmonth =0;
//		}
//		jsonMap.put("year", year);
//		jsonMap.put("month", month);
//		jsonMap.put("maxday", maxday);
//		jsonMap.put("dayofmonth", dayofmonth);
//		
//		String jsonStr = com.clip.util.json.JSONObject.toJSONString(jsonMap);
//		Struts2Utils.renderText(jsonStr);
//	}
//	public void getThisMonth(){
//		Calendar calendar=Calendar.getInstance();
//		Map<String,Object> jsonMap = new HashMap<String, Object>();
//		jsonMap.put("year", calendar.get(Calendar.YEAR));
//		jsonMap.put("month", calendar.get(Calendar.MONTH));
//		jsonMap.put("maxday", calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
//		jsonMap.put("dayofmonth", calendar.get(Calendar.DAY_OF_MONTH));
//		
//		String jsonStr = com.clip.util.json.JSONObject.toJSONString(jsonMap);
//		Struts2Utils.renderText(jsonStr);
//	}
//	public void getTodayDateInfo(){
//		Map<String,Object> infoMap=new LinkedHashMap<String,Object>();
//		Calendar today = Calendar.getInstance();
//		infoMap.put("year", today.get(Calendar.YEAR));
//		infoMap.put("month", today.get(Calendar.MONTH));
//		infoMap.put("day", today.get(Calendar.DAY_OF_MONTH));
//		infoMap.put("week", today.get(Calendar.WEEK_OF_YEAR));
//		Struts2Utils.renderText(ToolsUtils.getJSON(infoMap));
//		
////		Lunar lunar = new Lunar(calendar);
////		buffer.append("<span>");
////		buffer.append(CalendarToChinese.day_of_week2cn(calendar.get(Calendar.DAY_OF_WEEK)));
////		buffer.append("</span>，<span>");
////		buffer.append(calendar.get(Calendar.YEAR));
////		buffer.append("</span>年<span>");
////		buffer.append((calendar.get(Calendar.MONTH)+1));
////		buffer.append("</span>月<span>");
////		buffer.append(calendar.get(Calendar.DAY_OF_MONTH));
////		buffer.append("</span>日，第<span>");
////		buffer.append(calendar.get(Calendar.WEEK_OF_YEAR));
////		buffer.append("</span>周，农历<span>");
////		buffer.append(lunar.getLunarMonth());
////		buffer.append("</span>月<span>");
////		buffer.append(lunar.getLunarDay());
////		buffer.append("</span>");
////		String temp1=CalendarToChinese.calendar2solarterms(calendar);
////		if(temp1!=null&&temp1.length()>0){
////			buffer.append("，<span>"+temp1+"</span>");
////		}
////		temp1=CalendarToChinese.calendar2date(calendar);
////		if(temp1!=null&&temp1.length()>0){
////			buffer.append("，<span>"+temp1+"</span>");
////		}
////		//对于自定义节日需要查询
////		Struts2Utils.renderText(buffer.toString());
//		
//	}
//	
//	public void getTodayEvent(){
//		Calendar calendar=Calendar.getInstance();
//		User currentUser=(User) Struts2Utils.getSession().getAttribute(SessionAttributeKey.USER);
//		List events1=eventService.getTodayEvent(calendar,currentUser);
//		filterForbiddenEvent(events1,currentUser.getId(),calendar);
//		Struts2Utils.renderXml(ToolsUtils.getDOMEventForView(events1));
//	}
///*
//	private String getHoliday(User user,int year,int month,int day){
//		List<UserDate> listUserDates=this.userDateService.getUserHolidayByDay(user, year, month, day);
//		if(listUserDates!=null&&listUserDates.size()>0){
//			return listUserDates.get(0).getName();
//		}else{
//			List<SystemDate> listSystemDates=this.systemDateService.getSystemHolidayByDay(year, month, day);
//			if(listSystemDates!=null&&listSystemDates.size()>0){
//				return listSystemDates.get(0).getName();
//			}else
//				return "0";
//		}
//	}*/
//	
//	
//	public void acceptInvitedClip(){
//		User currentUser = (User) Struts2Utils.getSession().getAttribute(SessionAttributeKey.USER);
//		ClipEvent clipEvent = this.eventService.acceptInvitedClip(currentUser,eventid);
//		if(currentUser==null||currentUser.getId()<=0||clipEvent==null||clipEvent.getId()<=0)
//			Struts2Utils.renderText("");
//		Calendar firstDateOfMonth = Calendar.getInstance();
//		firstDateOfMonth.clear(Calendar.MILLISECOND);
//		firstDateOfMonth.clear(Calendar.SECOND);
//		firstDateOfMonth.clear(Calendar.MINUTE);
//		firstDateOfMonth.set(Calendar.HOUR_OF_DAY, 0);
//		firstDateOfMonth.set(Calendar.YEAR, this.year);
//		firstDateOfMonth.set(Calendar.MONTH,this.month);
//		Calendar endDateOfMonth = (Calendar) firstDateOfMonth.clone();
//		endDateOfMonth.add(Calendar.MONTH, +1);
//		Map reMap=new HashMap();
//		reMap.put("eventid", clipEvent.getId());
//		reMap.put("title", clipEvent.getTitle());
//		reMap.put("address", clipEvent.getAddress()==null||clipEvent.getAddress().length()==0?"":ToolsUtils.xmlCDATA(clipEvent.getAddress()));
//		String content=clipEvent.getContent();
//		reMap.put("content", content==null||content.length()==0?"":ToolsUtils.xmlCDATA(URLReplace.replace(content)));
//		reMap.put("eventtype", ClipEvent.eventtypeInt2Str(clipEvent.getEventtype()));
//		reMap.put("starttime", clipEvent.getBegintime());
//		reMap.put("endtime", clipEvent.getEndtime());
//		reMap.put("iswholeday", clipEvent.getIswholeday());
//		reMap.put("clocktime", clipEvent.getAlerttime());
////		reMap.put("deadlinetime", clipEvent.getDeadlinetime());
//		reMap.put("reliedclip", clipEvent.getReliedclip());
//		reMap.put("isvip", clipEvent.getIsvip());
//		reMap.put("processstatus", clipEvent.getProcessstatus());
////		List<String> names=this.eventService.getPublishname(clipEvent,currentUser);
////		if(names.size()>0){
////			reMap.put("publishname", names.get(0));
////			if(names.size()>1)
////				reMap.put("forwardname", names.get(1));
////		}
//		//(clip.begintime<="+begin+" and clip.endtime>="+begin+") or (clip.begintime>"+begin+" and clip.begintime<"+end+")) 
//		if(isBelongPassage(firstDateOfMonth,endDateOfMonth,clipEvent)){
//			reMap.put("iscrtmonth",1);
//			reMap.put("startday",getStartDayOfMonth(clipEvent.getBegintime(),firstDateOfMonth));
//			reMap.put("endday",getEndDayOfMonth(clipEvent.getEndtime(),endDateOfMonth));
//		}else{
//			reMap.put("iscrtmonth",0);
//		}
//		Struts2Utils.renderXml(ToolsUtils.getDOM(reMap));
//	}
//	
//	private boolean isBelongPassage(Calendar passageBegin,Calendar passageEnd,ClipEvent clipEvent){
//		if((clipEvent.getBegintime()<=passageBegin.getTimeInMillis() && clipEvent.getEndtime()>=passageBegin.getTimeInMillis())
//				||(clipEvent.getBegintime()>passageBegin.getTimeInMillis()&&clipEvent.getBegintime()<passageEnd.getTimeInMillis())){
//			return true;
//		}else{
//			return false;
//		}
//	}
//	
//	public void getEventsByMonth(){
//		Calendar calendar=Calendar.getInstance();
//		User currentUser=(User) Struts2Utils.getSession().getAttribute(SessionAttributeKey.USER);
//		if(this.year==0&&this.month==0){
//			this.year=calendar.get(Calendar.YEAR);
//			this.month=calendar.get(Calendar.MONTH);
//		}
//		List events1=eventService.getEventsByMonth(this.year,this.month,calendar,currentUser);
//		Map<String,Map> returnmap=organizeMonthViewMapAsXml(events1,currentUser);
//		Struts2Utils.renderXml(ToolsUtils.getDOM(returnmap));
//	}
//	
//	private void filterForbiddenEvent(List events1,Integer uid,Calendar time) {
//		List<ForbiddenEvent> list=forbiddenEventService.getForbiddenEvents(uid, time);
//		for (Iterator it = events1.iterator(); it.hasNext();) {
//			EventForView eventForView = (EventForView) it.next();
//			boolean isDel=false;
//			for (ForbiddenEvent forbiddenEvent : list) {
//				if(forbiddenEvent.getEventid().equals(eventForView.getEventid())&&
//						forbiddenEvent.getUid().equals(uid)){
//					it.remove();
//				}
//			}
//		}
//		
//	}
//	private Map<String,Map> organizeMonthViewMapAsXml(List list, User user) {
//		Map<String, Map> returnMap=new LinkedHashMap<String, Map>();
//		Calendar firstDateOfMonth=Calendar.getInstance();
//		firstDateOfMonth.clear(Calendar.MILLISECOND);
//		firstDateOfMonth.clear(Calendar.SECOND);
//		firstDateOfMonth.clear(Calendar.MINUTE);
//		firstDateOfMonth.set(Calendar.HOUR_OF_DAY, 0);
//		firstDateOfMonth.set(Calendar.YEAR, year);
//		firstDateOfMonth.set(Calendar.MONTH, month);
//		firstDateOfMonth.set(Calendar.DAY_OF_MONTH, 1);
//		Calendar lastDateOfMonth=(Calendar) firstDateOfMonth.clone();
//		lastDateOfMonth.set(Calendar.DAY_OF_MONTH,firstDateOfMonth.getActualMaximum(Calendar.DAY_OF_MONTH));
//		for (Object object : list) {
//			EventForView eventforview=(EventForView) object;
//			Map<String,Object> temp2=new HashMap<String,Object>();
//			temp2.put("eventid", eventforview.getEventid());
//			temp2.put("isClocked", ""+eventforview.isClocked());
//			temp2.put("isThisMonth", ""+eventforview.isThisMonth());
//			temp2.put("eventtype", eventforview.getEventtype());
//			temp2.put("starttime", eventforview.getStarttime().toString());
//			temp2.put("endtime", eventforview.getEndtime().toString());
//			temp2.put("iswholeday", eventforview.getIswholeday().toString());
//			temp2.put("content", eventforview.getContent());
//			temp2.put("clocktime", eventforview.getClocktime()==null?"":eventforview.getClocktime());
//			temp2.put("address", eventforview.getAddress());
//			temp2.put("title", eventforview.getTitle());
//			temp2.put("startday", getStartDayOfMonth(eventforview.getStarttime(),firstDateOfMonth));
//			temp2.put("endday", getEndDayOfMonth(eventforview.getEndtime(),lastDateOfMonth));
//			temp2.put("deadlinetime", eventforview.getDeadlinetime().toString());
//			temp2.put("reliedclip", eventforview.getReliedclip().toString());
//			temp2.put("isvip", eventforview.getIsvip().toString());
//			temp2.put("istodayortommorrow", ""+eventforview.isTodayOrTommorrow());
//			temp2.put("processstatus", eventforview.getProcessstatus().toString());
//			temp2.put("publishname", eventforview.getPublishname());
//			//temp2.put("date", firstDateOfWeek.getTimeInMillis());
//			returnMap.put("EventForView id="+eventforview.getEventid(), temp2);
//		}
//		return returnMap;
//	}
//	private Integer getStartDayOfMonth(Long starttime,Calendar firstDateOfMonth){
//		if(starttime<firstDateOfMonth.getTimeInMillis()){
//			return 1;
//		}else{
//			Calendar calendar=Calendar.getInstance();
//			calendar.setTimeInMillis(starttime);
//			return calendar.get(Calendar.DAY_OF_MONTH);
//		}
//	}
//	private Integer getEndDayOfMonth(Long endtime,Calendar lastDateOfMonth){
//		if(endtime>lastDateOfMonth.getTimeInMillis()){
//			return lastDateOfMonth.getActualMaximum(Calendar.DAY_OF_MONTH);
//		}else{
//			Calendar calendar=Calendar.getInstance();
//			calendar.setTimeInMillis(endtime);
//			return calendar.get(Calendar.DAY_OF_MONTH);
//		}
//	}
//	private Map<String,Map> organizeMonthViewMapAsXml(Map map,User user){
//		Map<String, Map> returnMap=new HashMap<String, Map>();
//		Set sets=map.keySet();
//		
//		Calendar firstDateOfMonth=Calendar.getInstance();
//		firstDateOfMonth.clear(Calendar.MILLISECOND);
//		firstDateOfMonth.clear(Calendar.SECOND);
//		firstDateOfMonth.clear(Calendar.MINUTE);
//		firstDateOfMonth.set(Calendar.HOUR_OF_DAY, 0);
//		firstDateOfMonth.set(Calendar.YEAR, year);
//		firstDateOfMonth.set(Calendar.MONTH,month);
//		firstDateOfMonth.set(Calendar.DAY_OF_MONTH, 1);
//		
//		Calendar startdate=(Calendar) firstDateOfMonth.clone();
//		startdate.add(Calendar.DAY_OF_MONTH, Calendar.SUNDAY-startdate.get(Calendar.DAY_OF_WEEK));
//		
//		Calendar lastDateOfMonth=(Calendar) firstDateOfMonth.clone();
//		lastDateOfMonth.set(Calendar.DAY_OF_MONTH,firstDateOfMonth.getActualMaximum(Calendar.DAY_OF_MONTH));
//		
//		Calendar lastDate=(Calendar) lastDateOfMonth.clone();
//		lastDate.add(Calendar.DAY_OF_MONTH, Calendar.SATURDAY-lastDate.get(Calendar.DAY_OF_WEEK));
//		returnMap.put("year_month value="+this.year+"_"+this.month,new HashMap());
//		while(!startdate.after(lastDate)){
////			String holidayname=getHoliday(user, startdate.get(Calendar.YEAR), startdate.get(Calendar.MONTH), startdate.get(Calendar.DAY_OF_MONTH));
//			String holidayname="";
//			if(!holidayname.equals("0")){
//				returnMap.put("month"+dateFormat.format(startdate.getTime())+" holidayname="+holidayname, new HashMap());
//			}
//			if(map.containsKey(startdate.getTimeInMillis())){
//				List list=(List) map.get(startdate.getTimeInMillis());
//				Object val = null;
//				if (list != null && list.size() > 0) {
//					Map<String,Object> temp1=new HashMap<String,Object>();
//					for (Object tempObj : list) {
//						EventForView eventforview=(EventForView) tempObj;
//						Map<String,Object> temp2=new HashMap<String,Object>();
//						temp2.put("eventid", eventforview.getEventid());
//						temp2.put("starthour", eventforview.getStarthour().toString());
//						temp2.put("endhour", eventforview.getEndhour().toString());
//						temp2.put("isAllDay", ""+eventforview.isAllDay());
//						temp2.put("isClocked", ""+eventforview.isClocked());
//						temp2.put("isThisMonth", ""+eventforview.isThisMonth());
//						temp2.put("eventtype", eventforview.getEventtype());
//						temp2.put("starttime", eventforview.getStarttime().toString());
//						temp2.put("endtime", eventforview.getEndtime().toString());
//						temp2.put("iswholeday", eventforview.getIswholeday().toString());
//						temp2.put("content", eventforview.getContent());
//						temp2.put("clocktime", eventforview.getClocktime()==null?"":eventforview.getClocktime());
//						temp2.put("address", eventforview.getAddress());
//						temp2.put("title", eventforview.getTitle());
//						temp1.put("EventForView id="+eventforview.getEventid(), temp2);
//					}
//					
//					returnMap.put("month"+dateFormat.format(startdate.getTime())+" holidayname="+holidayname, temp1);
//				}
//			}
//			
//			startdate.add(Calendar.DAY_OF_MONTH, 1);
//		}
//		
//		return returnMap;
//	}
//	
//	
//	private int year;
//	private int month;
//	private int eventid;
//	
//	public int getYear() {
//		return year;
//	}
//
//	public void setYear(int year) {
//		this.year = year;
//	}
//
//	public int getMonth() {
//		return month;
//	}
//
//	public void setMonth(int month) {
//		this.month = month;
//	}
//	public int getEventid() {
//		return eventid;
//	}
//	public void setEventid(int eventid) {
//		this.eventid = eventid;
//	}
//	
}
